<!-- 采购类 -->
<template>
	<u-form 
		:rules="rules"
		:model="purchaseyFeeInfo"
		v-if="feeCategory=='1'"
		labelWidth="auto" 
		class='info-form-bg'
		labelPosition="top"
		ref="purchaseyFeeInfoForm"
		:labelStyle="{
			fontSize: '14px',
			color: '#B2B2B2',
			lineHight: '20px'
		}"
	>
	  <u-form-item label="采购大类:" required prop="bigCategory">
		<selectListTag
		  class="w-100"
		  v-model="purchaseyFeeInfo.bigCategory"
		  objectField="purchaseyFeeInfo.bigCategory"
		  placeholder="请选择采购大类"
		  :chooseList='bigCategoryList'
		  @change='changeBigCategory'
			objectProperties="id"
			suffixIcon="arrow-down-fill"
			:suffixIconStyle="{color: '#B2B2B2'}"
		  border="surround"/>
	  </u-form-item>
	  <u-form-item label="采购小类:" required prop="smallCategory">
		<selectListTag
		  class="w-100"
		  :disabled="!purchaseyFeeInfo.bigCategory"
		  v-model="purchaseyFeeInfo.smallCategory"
		  objectField="purchaseyFeeInfo.smallCategory"
		  :chooseList='smallCategoryList'
			objectProperties="id"
			@change='changeSmallCategory'
		  placeholder="请选择采购小类"
			suffixIcon="arrow-down-fill"
			:suffixIconStyle="{color: '#B2B2B2'}"
		  border="surround"/>
	  </u-form-item>
	  <u-form-item label="项目名称:" prop="projectId">
		  <h-select-project-input-popup
		    v-model="purchaseyFeeInfo.projectId"
		    :disabled="(!teamId&&!companyId) || showFlowSubmitButton"
		    :signUnit="companyId"
				:teamId="teamId"
				:queryParamType="'1'"
		    class="w-100"
		    placeholder="请选择项目名称"
		    border="surround"
		    suffixIcon="arrow-down-fill"
		    :suffixIconStyle="{ color: '#B2B2B2' }"
		    @realChange="handleProjectSelect"/>
	  </u-form-item>
		<u-form-item label="项目编号:" prop="projectCode">
		  <u--input disabled v-model='purchaseyFeeInfo.projectCode' placeholder="请输入项目编号"/>
		</u-form-item>
		<u-form-item label="业绩归属年度:" prop="performanceAttributionYear">
			<h-select-input-tag
			  class="w-100"
			  v-model="purchaseyFeeInfo.performanceAttributionYear"
			  objectField="purchaseyFeeInfo.performanceAttributionYear"
			  placeholder="请选择业绩归属年度"
			  border="surround"
				disabled
				suffixIcon="arrow-down-fill"
				:suffixIconStyle="{ color: '#B2B2B2' }" 
			  dictName="yjgsnd"
			/>
		</u-form-item>
	  <u-form-item label="关联采购合同:" required prop="relContractId" >
			<template v-if="!purchaseyFeeInfo.projectId">
				<h-select-purchase-contract-input-popup
					placeholder="请选择关联采购合同"
					showName="1"
					htlx="2"
					:disabled="(!companyId&&!teamId) || showFlowSubmitButton"
					:projectId="purchaseyFeeInfo.projectId"
					:demandCompanName="purchaseyFeeInfo.projectId?null:companyId"
					:teamId="purchaseyFeeInfo.projectId?null:teamId"
					v-model="purchaseyFeeInfo.relContractId"
					border="surround"
					style="width: 100%"
					suffixIcon="arrow-down-fill"
					:suffixIconStyle="{ color: '#B2B2B2' }"
					@realChange='contractHTChange'
				></h-select-purchase-contract-input-popup>
			</template>
			
			<template v-else>
				<h-select-contract-manager-input-popup
					:disabled="!purchaseyFeeInfo.projectId || showFlowSubmitButton"
					showName="1"
					isCategoryType="1"
					:projectId="purchaseyFeeInfo.projectId"
					htlx="2"
				  v-model="purchaseyFeeInfo.relContractId"
				  placeholder="请选择合同"
				  border="surround"
				  style="width: 100%"
				  suffixIcon="arrow-down-fill"
					@realChange='getProjectContract'
				  :suffixIconStyle="{ color: '#B2B2B2' }"
				></h-select-contract-manager-input-popup>
			</template>
	  </u-form-item>
	  
	  <u-form-item label="发票类型:" prop="isSpecial" required>
	  	<h-select-input-tag
	  	  class="w-100"
	  	  v-model="purchaseyFeeInfo.isSpecial"
	  	  objectField="purchaseyFeeInfo.isSpecial"
	  	  placeholder="请选择发票类型"
	  	  border="surround"
				suffixIcon="arrow-down-fill"
				:suffixIconStyle="{ color: '#B2B2B2' }" 
	  	  dictName="cost_invoice_type"
	  	  @change='isSpecialChange'/>
	  </u-form-item>
		<template v-if="purchaseyFeeInfo.projectId">
			<u-form-item label="收款合同金额(元):" prop="contractTotalAmount">
					<u--input disabled v-model='purchaseyFeeInfo.contractTotalAmount' placeholder="请输入应付款金额"/>
			</u-form-item>
			<u-form-item label="项目已回款金额(元)" prop="contractActualCollectAmount">
					<u--input disabled v-model='purchaseyFeeInfo.contractActualCollectAmount'  placeholder="请输入项目已回款金额"/>
			</u-form-item>
		</template>
	  
	  <!-- <u-form-item label="合同款项:" prop="contractPaymentId" required>
	  	<selectPurchaseContract
				muitFlag
				v-if="!purchaseyFeeInfo.projectId"
	  		showName="1"
	  		htlx="2"
				:disabled="!purchaseyFeeInfo.relContractId"
	  		:billId="purchaseyFeeInfo.relContractId"
	  		v-model="purchaseyFeeInfo.contractPaymentId"
	  		placeholder="请选择合同款项"
	  		border="surround"
	  		style="width: 100%"
	  		suffixIcon="arrow-down-fill"
	  		:suffixIconStyle="{ color: '#B2B2B2' }"
				@realChange='getContractPayment'/>
			
			<h-select-checkoutlist-input-popup
				v-else
				:muitFlag="true"
				:disabled="!purchaseyFeeInfo.relContractId"
			  v-model="purchaseyFeeInfo.contractPaymentId"
				:contractId="purchaseyFeeInfo.relContractId"
			  placeholder="请选择合同款项"
			  border="surround"
			  style="width: 100%"
			  suffixIcon="arrow-down-fill"
			  :suffixIconStyle="{ color: '#B2B2B2' }"
				@realChange="contractPaymentChange"
			></h-select-checkoutlist-input-popup>
	  </u-form-item> -->
	  
	  <u-form-item label="应付款金额(元):" prop="paymentAmount">
	  		<u--input disabled v-model='purchaseyFeeInfo.paymentAmount' placeholder="请输入应付款金额"/>
	  </u-form-item>
	  <u-form-item label="已付金额(元)" prop="collectedAmount">
	  		<u--input disabled v-model='purchaseyFeeInfo.collectedAmount'  placeholder="请输入已付金额"/>
	  </u-form-item>
	  <u-form-item label="未付金额(含扣款)(元)" prop="unpaymentAmount">
	  		<u--input disabled v-model='purchaseyFeeInfo.unpaymentAmount' placeholder="请输入未付金额"/>
	  </u-form-item>
	  
		<u-form-item label="报销金额(元):" required prop="amount">
			<h-money-input placeholder="请输入报销金额" v-model='purchaseyFeeInfo.amount' @blur='inputAmount'></h-money-input>
		</u-form-item>
		<u-form-item label="税费金额(元):" prop="taxation"  :required="!isSpecialDisabled">
			<h-money-input placeholder="请输入税费金额" :disabled="isSpecialDisabled" :max="purchaseyFeeInfo.amount" @blur='inputAmount' v-model='purchaseyFeeInfo.taxation'></h-money-input>
		</u-form-item>
		<u-form-item label="未税金额(元):" prop="untaxedAmount">
			<u--input disabled v-model='purchaseyFeeInfo.untaxedAmount' placeholder="请输入未税金额"/>
		</u-form-item>
		<u-form-item label="税率(%):" prop="taxRate" :required="!isTaxRateDisabled">
			<h-number-input
				placeholder="请输入税率"
				v-model="purchaseyFeeInfo.taxRate"
				:disabled="isTaxRateDisabled"
				:digit="0"
				:max="99999999"
				:min="0"
			></h-number-input>
		</u-form-item>
	</u-form>
</template>

<script>
	import selectListTag from './comp/select-list-tag.vue'
	import {
		Decimal
	} from 'decimal.js'
	import http from '@/utils/request'
	import { queryAllParent,queryChildrenByParentId } from '@/api/finance/ErpFinanceRepaymentSlipForm'
	import selectPurchaseContract from './comp/select-purchase-contract-popup.vue'
	export default {
		components:{selectListTag,selectPurchaseContract},
		props:{
			companyId:{
				type:String,
				default:''
			},
			teamId:{
				type:String,
				default:''
			},
			feeCategory:{
				type:String,
				default:''
			},
			//表单模式：true流程表单 false普通表单
			showFlowSubmitButton: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				isSpecialDisabled:false, // 判断税费金额是否填写
				isTaxRateDisabled:false, // 判断税率是否填写
				billId:'',//选择采购合同的id
				bigCategoryList:[],//大类的集合
				smallCategoryList:[],//小类的集合
				showNew: false,
				purchaseyFeeInfo:{
					bigCategory:"",//采购大类
					smallCategory:'',//采购小类
					projectId:"",//项目名称
					projectCode:"",//项目编号
					performanceAttributionYear: "", // 业绩归属年度
					relContractId:'',//关联采购合同
					isSpecial:'',//发票类型
					// contractPaymentId:'',//合同款项
					paymentAmount:'',//应付款金额(元)
					collectedAmount:'',//已付金额(元)
					unpaymentAmount:'',//未付金额（含扣款）(元)
					amount:'',//报销金额(元)
					taxation:'',//税费金额(元)
					untaxedAmount:'',//未税金额(元)
					taxRate: '',// 税率
				},
				
				rules:{
					bigCategory: [{ required: true, message: '请选择采购大类!', trigger: 'change' }],
					smallCategory: [{ required: true, message: '请选择采购小类!', trigger: 'change' }],
					relContractId: [{ required: true, message: '请选择关联采购合同!', trigger: 'change' }],
					isSpecial: [{ required: true, message: '请选择发票类型!', trigger: 'change' }],
					// contractPaymentId: [{ required: true, message: '请选择合同款项!', trigger: 'change' }],
					amount: [
						{ required: true, message: '请输入报销金额!', trigger: ['change', 'blur'] },
						{ pattern:/^(?!0\.00)(?!0$)([1-9]\d*|0)(\.\d{2})?$/, message: '请输入正确的金额!', trigger: ['change', 'blur']}
					],
					taxRate: [{ required: true, message: '请填写税率!', trigger: ['change', 'blur'] }],
				}
			}
		},
		async mounted() {
			/* 获取大类的信息 */
			let res = await queryAllParent()
			if(res.success&&res.result.length>0){
				this.bigCategoryList=res.result
				for (let it of this.bigCategoryList) {
					it.title=it.categoryName
					it.code= it.id
				}
			}
		},
		methods: {
			// 清除数据
			toRest(){
				this.purchaseyFeeInfo={
					bigCategory:"",//采购大类
					smallCategory:'',//采购小类
					projectId:"",//项目名称
					projectCode: "", // 项目编号
					performanceAttributionYear: "", // 业绩归属年度
					relContractId:'',//关联采购合同
					isSpecial:'',//发票类型
					// contractPaymentId:'',//合同款项
					paymentAmount:'',//应付款金额(元)
					collectedAmount:'',//已付金额(元)
					unpaymentAmount:'',//未付金额（含扣款）(元)
					amount:'',//报销金额(元)
					taxation:0.00,//税费金额(元)
					untaxedAmount: '',//未税金额(元)
					taxRate: 0,// 税率
				}
				this.specialRules()
			},
			// 获取小类
			async changeBigCategory(code,item){
				let res = await queryChildrenByParentId({
					parentId:item.id
				})
				if(res.success&&res.result.length>0){
					this.smallCategoryList=res.result
					for (let it of this.smallCategoryList) {
						it.title=it.categoryName
						it.code= it.id
					}
				}
			},
			changeSmallCategory(code,item){
				if (code) {
					let res = this.smallCategoryList.filter(val => val.id == code);
					if(res[0]&&res[0].checkPosition){
						this.$set(this.purchaseyFeeInfo, 'checkPosition', res[0].checkPosition);
					} else {
						this.$set(this.purchaseyFeeInfo, 'checkPosition', '');
					}
				}
			},
			
			// 发票类型验证规则
			specialRules(){
				// 0 普票 1专票 2其他
				if(this.purchaseyFeeInfo.isSpecial == '0'){
					// 普票：税费和税率默认为0，发起人不可编辑和修改（流程中也不可修改）
					this.$delete(this.rules, 'taxation');
					this.$delete(this.rules, 'taxRate');
					this.isSpecialDisabled=true;
					this.isTaxRateDisabled=true;
				}else if (this.purchaseyFeeInfo.isSpecial == '1'){
					// 专票：税费和税率为必填，发起人可编辑和修改 （税率计算公式：税费金额/未税金额取整，流程中都可修改）
					this.$set(this.rules, 'taxRate', [{ required: true, message: '请输入正确的税率!'}]);
					this.$set(this.rules, 'taxation', [
						{ required: true, message: '请输入税费金额!', trigger: 'blur' },
						// 税费金额不能为零
						{ pattern: /^(?!0\.00)(?!0$)([1-9]\d*|0)(\.\d{2})?$/, message: '请输入正确的税费金额!' }
					])
					this.isSpecialDisabled=false;
					this.isTaxRateDisabled=false;
				} else {
					// 其他或者不填：税费金额必填默认为0，发起人可修改，税率默认为0，发起人不可编辑和修改（流程中可以修改税费金额，不可修改税率）
					this.$delete(this.rules, 'taxRate');
					this.$set(this.rules, 'taxation', [
						{ required: true, message: '请输入税费金额!', trigger: 'blur' },
						// 税费金额可以为零
						{ pattern: /^(([0-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的税费金额!' }
					])
					this.isSpecialDisabled=false;
					this.isTaxRateDisabled=true;
				}
			},
			isSpecialChange(){
				this.$refs.purchaseyFeeInfoForm.clearValidate('taxation')
				if (this.purchaseyFeeInfo.isSpecial == 0) {
					// 普票：税费和税率默认为0，发起人不可编辑和修改（流程中也不可修改）
					this.$set(this.purchaseyFeeInfo, 'taxation',0);
					this.$set(this.purchaseyFeeInfo, 'taxRate',0);
					this.$delete(this.rules, 'taxation');
					this.$delete(this.rules, 'taxRate');
					this.$refs.purchaseyFeeInfoForm.clearValidate('taxation');
					this.$refs.purchaseyFeeInfoForm.clearValidate('taxRate');
					this.isSpecialDisabled=true;
					this.isTaxRateDisabled=true;
				} else {
					this.$refs.purchaseyFeeInfoForm.clearValidate('taxation')
					if (this.purchaseyFeeInfo.isSpecial == 1) {
						// 专票：税费和税率为必填，发起人可编辑和修改 （税率计算公式：税费金额/未税金额取整，流程中都可修改）
						this.$set(this.purchaseyFeeInfo, 'taxation',null);
						this.$set(this.purchaseyFeeInfo, 'taxRate',null);
						this.$set(this.rules, 'taxRate', [{ required: true, message: '请输入正确的税率!'}]);
						this.$set(this.rules, 'taxation', [
							{ required: true, message: '请输入税费金额!', trigger: 'blur' },
							{ pattern: /^(?!0\.00)(?!0$)([1-9]\d*|0)(\.\d{2})?$/, message: '请输入正确的税费金额!' }
						])
						this.isSpecialDisabled=false;
						this.isTaxRateDisabled=false;
					} else {
						// 其他或者不填：税费金额必填默认为0，发起人可修改，税率默认为0，发起人不可编辑和修改（流程中可以修改税费金额，不可修改税率）
						this.$set(this.purchaseyFeeInfo, 'taxation',0);
						this.$set(this.purchaseyFeeInfo, 'taxRate',0);
						this.$delete(this.rules, 'taxRate');
						this.$set(this.rules, 'taxation', [
							{ required: true, message: '请输入税费金额!', trigger: 'blur' },
							{ pattern: /^(([0-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的税费金额!' }
						])
						this.isSpecialDisabled=false;
						this.isTaxRateDisabled=true;
					}
				}
				this.$emit('inputAmount', '2')
			},
			handleProjectSelect(data){
				if(data){
					this.$set(this.purchaseyFeeInfo, 'projectCode', data.finalNo);
					this.$set(this.purchaseyFeeInfo, 'performanceAttributionYear', data.year);
					if(this.purchaseyFeeInfo.relContractId){
						this.$set(this.purchaseyFeeInfo, 'relContractId','');
						// this.$set(this.purchaseyFeeInfo,"contractPaymentId",'');
						this.$set(this.purchaseyFeeInfo,"paymentProportion",''); // 付款比例字段已废除
						this.$set(this.purchaseyFeeInfo,"paymentAmount",0);
						this.$set(this.purchaseyFeeInfo,"collectedAmount",0);
						this.$set(this.purchaseyFeeInfo,"unpaymentAmount",0);
						this.$emit('projectChange')
					}
					//切换项目清空收款信息：accountName、bankName、accountNo
					if(this.purchaseyFeeInfo.projectId){
						http.get('/api/erp/omc/contractmanager/erpOmcContractManagerFinal/list2',{'xmmc':this.purchaseyFeeInfo.projectId,'htlx':"1","status":"2,3"}).then(res => {
							if (res.success) {
									let resResult=res.result;
									if(resResult.records){
										let contractInfo=resResult.records[0]
										this.$set(this.purchaseyFeeInfo,"contractTotalAmount",contractInfo.receivablesPaymentMoney);
										this.$set(this.purchaseyFeeInfo,"contractActualCollectAmount",contractInfo.realCollectionPaymentMoney);
									}
							}
						})
					}else{
						this.$set(this.purchaseyFeeInfo,"contractTotalAmount",null);
						this.$set(this.purchaseyFeeInfo,"contractActualCollectAmount",null);
					}
				} else {
					this.$set(this.purchaseyFeeInfo, 'projectCode', null);
					this.$set(this.purchaseyFeeInfo, 'performanceAttributionYear', null);
				}
			},
			
			// 关联采购合同
			contractHTChange(data){
				// this.billId=item.id
				if(data){
					// //切换合同带出公司名称到收款户名 ： 条件为：结算方式为转账，转账类型为供应商
					this.$emit('getInformation', data.supplyCompanName) // 获取账户信息
					
					this.$set(this.purchaseyFeeInfo,"teamId",data.teamId);
					this.$set(this.purchaseyFeeInfo,"isSpecial",data.invoiceCategory);
					this.isSpecialChange(); // 发票类型
					// if(this.purchaseyFeeInfo.contractPaymentId){
					// 	this.$set(this.purchaseyFeeInfo,"contractPaymentId",'');
					// 	this.$set(this.purchaseyFeeInfo,"paymentProportion",'');
					// 	this.$set(this.purchaseyFeeInfo,"paymentAmount",'');
					// 	this.$set(this.purchaseyFeeInfo,"collectedAmount",0);
					// 	this.$set(this.purchaseyFeeInfo,"unpaymentAmount",0);
					// }
					
					if (this.purchaseyFeeInfo.relContractId){
						http.get('/api/erp/purchase/contract/erpPurchaseContract/queryById', {id: this.purchaseyFeeInfo.relContractId}).then((res) => {
							if (res.success) {
								let resData = res.result;
								if (resData) {
									this.$set(this.purchaseyFeeInfo, 'paymentAmount', resData.totalAmount);
									this.$set(this.purchaseyFeeInfo, 'collectedAmount', resData.practicalPaidAmount);
									let deductMoney = resData.deductCountAmount;
									let unpaymentAmount = 0;
									if (deductMoney != null && deductMoney != '') {
										unpaymentAmount = (resData.totalAmount.toFixed(2) - resData.practicalPaidAmount.toFixed(2) - deductMoney.toFixed(2)).toFixed(2)
									} else {
										unpaymentAmount = (resData.totalAmount.toFixed(2) - resData.practicalPaidAmount.toFixed(2)).toFixed(2)
									}
									this.$set(this.purchaseyFeeInfo, 'unpaymentAmount', unpaymentAmount);
								}
							}
						})
					} else {
						this.$set(this.purchaseyFeeInfo, 'paymentAmount', 0);
						this.$set(this.purchaseyFeeInfo, 'collectedAmount', 0);
						this.$set(this.purchaseyFeeInfo, 'unpaymentAmount', 0);
					}
				} else {
					this.$emit('getInformation', '') // 获取账户信息
					this.$set(this.purchaseyFeeInfo,"teamId", '');
					this.$set(this.purchaseyFeeInfo,"isSpecial", '');
					this.isSpecialChange(); // 发票类型
					// if(this.purchaseyFeeInfo.contractPaymentId){
					// 	this.$set(this.purchaseyFeeInfo,"contractPaymentId",'');
					// 	this.$set(this.purchaseyFeeInfo,"paymentProportion",'');
					// 	this.$set(this.purchaseyFeeInfo,"paymentAmount",'');
					// 	this.$set(this.purchaseyFeeInfo,"collectedAmount",0);
					// 	this.$set(this.purchaseyFeeInfo,"unpaymentAmount",0);
					// }
				}
			},
			getProjectContract(data){
				if(data){
					// if(this.purchaseyFeeInfo.contractPaymentId){
					// 	this.$set(this.purchaseyFeeInfo,"contractPaymentId",null);
					// 	this.$set(this.purchaseyFeeInfo,"paymentAmount",0);
					// 	this.$set(this.purchaseyFeeInfo,"collectedAmount",0);
					// 	this.$set(this.purchaseyFeeInfo,"unpaymentAmount",0);
					// }
					
					if (this.purchaseyFeeInfo.relContractId) {
						http.get(
						'/api/erp/omc/contractmanager/erpOmcContractManagerFinal/queryById', 
						{ id: this.purchaseyFeeInfo.relContractId }).then((res) => {
							if (res.success) {
								let resData = res.result;
								if (resData) {
									this.$set(this.purchaseyFeeInfo, 'paymentAmount', resData.receivablesPaymentMoney);
									this.$set(this.purchaseyFeeInfo, 'collectedAmount', resData.realCollectionPaymentMoney);
									let deductMoney = resData.deductMoney;
									let unpaymentAmount = 0;
									if (deductMoney != null && deductMoney != '') {
										unpaymentAmount = (resData.receivablesPaymentMoney.toFixed(2) - resData.realCollectionPaymentMoney.toFixed(2) - deductMoney.toFixed(2)).toFixed(2)
									} else {
										unpaymentAmount = (resData.receivablesPaymentMoney.toFixed(2) - resData.realCollectionPaymentMoney.toFixed(2)).toFixed(2)
									}
									this.$set(this.purchaseyFeeInfo, 'unpaymentAmount', unpaymentAmount);
								}
							}
						})
					} else {
						this.$set(this.purchaseyFeeInfo, 'paymentAmount', 0);
						this.$set(this.purchaseyFeeInfo, 'collectedAmount', 0);
						this.$set(this.purchaseyFeeInfo, 'unpaymentAmount', 0);
					}
				}
			},
			// 合同款项变化
			getContractPayment (data) {
				if(data.length>0){
					let paymentAmount=0;
					let paymentTotalAmount=0;
					for(var i=0;i<data.length;i++){
						paymentAmount+=data[i].paymentAmount;
						paymentTotalAmount+=data[i].paymentTotalAmount;
					}
					this.$set(this.purchaseyFeeInfo,"paymentAmount",paymentAmount.toFixed(2));
					this.$set(this.purchaseyFeeInfo,"collectedAmount",paymentTotalAmount.toFixed(2));
					this.$set(this.purchaseyFeeInfo,"unpaymentAmount",(paymentAmount-paymentTotalAmount).toFixed(2));
				}else{
					this.$set(this.purchaseyFeeInfo,"paymentAmount",0);
					this.$set(this.purchaseyFeeInfo,"collectedAmount",0);
					this.$set(this.purchaseyFeeInfo,"unpaymentAmount",0);
				}
				this.isSpecialChange(); // 发票类型
			},
			inputAmount () {
				let amount = 0
				if(Number(this.purchaseyFeeInfo.amount) && (Number(this.purchaseyFeeInfo.taxation) || Number(this.purchaseyFeeInfo.taxation)==0)){
					amount	=(this.purchaseyFeeInfo.amount-this.purchaseyFeeInfo.taxation).toFixed(2);
					if(amount>0){
						this.$set(this.purchaseyFeeInfo,'untaxedAmount',amount);
						if (this.purchaseyFeeInfo.isSpecial == 1) {
							// 专票, 未税金额 = 报销金额 - 税费金额 
							this.$set(this.purchaseyFeeInfo,'taxRate',(this.purchaseyFeeInfo.taxation/this.purchaseyFeeInfo.untaxedAmount*100).toFixed(0));
						} else {
							// 不是专票 默认为零
							this.$set(this.purchaseyFeeInfo, 'taxRate',0);
						}
					}else{
						this.$set(this.purchaseyFeeInfo,'untaxedAmount',0);
						this.$set(this.purchaseyFeeInfo,'taxRate',0);
					}
				}
				this.$emit('inputAmount', '2')
			},
			contractPaymentChange(data){
				if(data.length > 0){
					let paymentAmount = 0;
					let paymentTotalAmount = 0;
					for(var i = 0; i < data.length; i++){
						paymentTotalAmount +=  Number(data[i].realCollectionPaymentMoney);
						paymentAmount += Number(data[i].paymentMoney);
					}
					this.purchaseyFeeInfo.paymentAmount = paymentAmount.toFixed(2)
					this.purchaseyFeeInfo.collectedAmount = paymentTotalAmount.toFixed(2)
					this.purchaseyFeeInfo.unpaymentAmount=(paymentAmount - paymentTotalAmount).toFixed(2)
				}else{
					this.purchaseyFeeInfo.paymentAmount = 0
					this.purchaseyFeeInfo.collectedAmount = 0
					this.purchaseyFeeInfo.unpaymentAmount= 0
				}
			},
			
			onSubmit() {
				this.specialRules()
				return this.$refs.purchaseyFeeInfoForm.validate()
			}
		},
	}
</script>

<style lang="scss" scoped>
	
</style>